package com.wits.qso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name="qso_stuaidcase")
public class StuAidCase extends BaseEntity {
	/**书柜代码*/
	private String id;
	/**学生编号*/
	private Student stuId;
	/**附件编号*/
	private StuAid stuAidId;
	
	@Id
	@GenericGenerator(name = "idGen", 
					strategy = "com.wits.platform.common.id.generator.IDGenerator",
					parameters={ 
								@Parameter(name = "segment_value", value = "QSO_STUAIDCASE_ID"),
								@Parameter(name="table_name",value="wits_id_generator"),
								@Parameter(name="value_column_name",value="gen_value"),
								@Parameter(name="segment_column_name",value="gen_name"),
								@Parameter(name="segment_value_length",value="10"),
								@Parameter(name="sq_format",value="%08d"),
								@Parameter(name="sq_prefix",value="SC")
					})
	@GeneratedValue(generator = "idGen")
	@Column(name = "stuaidcase_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="stuaidcase_stuid")
	public Student getStuId() {
		return stuId;
	}

	public void setStuId(Student stuId) {
		this.stuId = stuId;
	}

	@ManyToOne
	@JoinColumn(name="stuaidcase_stuaidid")
	public StuAid getStuAidId() {
		return stuAidId;
	}

	public void setStuAidId(StuAid stuAidId) {
		this.stuAidId = stuAidId;
	}

	@Override
	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String toString() {
		return "{\"id\":\"" + this.id 
				+ "\",\"stuname\":\"" + this.stuId.getStuName()
				+ "\",\"name\":\"" + this.stuAidId.getName() 
				+ "\",\"intro\":\"" + this.stuAidId.getIntro()
				+ "\" }";
	}
	
}
